﻿@page
@model CampusNews.Pages.Users.IndexModel

@{
    ViewData["Title"] = "Index";
}

<h1>Index</h1>

<p>
    <a asp-page="Create">Create New</a>
</p>
<table class="table">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.User[0].Email)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.User[0].Token)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.User[0].TokenExpiration)
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
@foreach (var item in Model.User) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Email)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Token)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.TokenExpiration)
            </td>
            <td>
                <a asp-page="./Details" asp-route-id="@item.Id">Details</a> 
                
                    @if (!string.IsNullOrEmpty(Model.UserEmail))
                    {
                        <a asp-page="./Edit" asp-route-id="@item.Id">Edit</a>
                        <a asp-page="./Delete" asp-route-id="@item.Id">Delete</a>
                    }
            </td>
        </tr>
}
    </tbody>
</table>
